﻿using BAASearchLib;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;

namespace TestProject
{


    [TestClass()]
    public class CompareFileTypeTest
    {
        private static FileInfo txtFile;
        private static FileInfo docFile;
        private static FileInfo docxFile;

        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        [ClassInitialize()]
        public static void ClassInitializer(TestContext testContext)
        {
            txtFile = new FileInfo(@"C:\TestData\TextFile.txt");
            docFile = new FileInfo(@"C:\TestData\DocFile.doc");
            docxFile = new FileInfo(@"C:\TestData\DocxFile.docx");
        }

        [TestMethod()]
        public void CompareTxtFileTypeTest()
        {
            FileComparer comparer = new CompareFileType("txt");

            Assert.IsTrue(comparer.Compare(txtFile));
            Assert.IsFalse(comparer.Compare(docFile));
            Assert.IsFalse(comparer.Compare(docxFile));
        }

        [TestMethod()]
        public void CompareDocFileTypeTest()
        {
            FileComparer comparer = new CompareFileType("doc");

            Assert.IsFalse(comparer.Compare(txtFile));
            Assert.IsTrue(comparer.Compare(docFile));
            Assert.IsFalse(comparer.Compare(docxFile));
        }

        [TestMethod()]
        public void CompareDocxFileTypeTest()
        {
            FileComparer comparer = new CompareFileType("docx");

            Assert.IsFalse(comparer.Compare(txtFile));
            Assert.IsFalse(comparer.Compare(docFile));
            Assert.IsTrue(comparer.Compare(docxFile));
        }

        [TestMethod()]
        public void CompareBadFileTypeTest()
        {
            FileComparer comparer = new CompareFileType("bad");

            Assert.IsFalse(comparer.Compare(txtFile));
            Assert.IsFalse(comparer.Compare(docFile));
            Assert.IsFalse(comparer.Compare(docxFile));
        }


    }
}
